package com.cndongtai.dao.impl;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Repository;

import com.cndongtai.dao.BaseDao;
import com.cndongtai.dao.inter.ChargeCountMapper;
import com.cndongtai.po.ChargeCount;
import com.cndongtai.vo.UserChargeCountBean;

@Repository("chargeCountDao")
public class ChargeCountDao extends BaseDao implements ChargeCountMapper {

	@Override
	public ChargeCount queryChargeCountByUserId(Long userId) {
		SqlSession sqlSession = getSqlSession();
		try {
			ChargeCountMapper operation = sqlSession.getMapper(ChargeCountMapper.class);
			return operation.queryChargeCountByUserId(userId);
		}catch(Exception e) {
			e.printStackTrace();
		}finally {
			sqlSession.close();
		}
		
		return null;
	}

	@Override
	public boolean addChargeCount(ChargeCount chargeCount) {
		SqlSession sqlSession = getSqlSession();
		try {
			ChargeCountMapper operation = sqlSession.getMapper(ChargeCountMapper.class);
			return operation.addChargeCount(chargeCount);
		}catch(Exception e) {
			e.printStackTrace();
		}finally {
			sqlSession.close();
		}
		
		return false;
	}

	@Override
	public boolean updateChargeCount(ChargeCount chargeCount) {
		SqlSession sqlSession = getSqlSession();
		try {
			ChargeCountMapper operation = sqlSession.getMapper(ChargeCountMapper.class);
			return operation.updateChargeCount(chargeCount);
		}catch(Exception e) {
			e.printStackTrace();
		}finally {
			sqlSession.close();
		}
		
		return false;
	}

	@Override
	public int queryChargeCountOrder(ChargeCount chargeCount) {
		SqlSession sqlSession = getSqlSession();
		try {
			ChargeCountMapper operation = sqlSession.getMapper(ChargeCountMapper.class);
			return operation.queryChargeCountOrder(chargeCount);
		}catch(Exception e) {
			e.printStackTrace();
		}finally {
			sqlSession.close();
		}
		
		return 0;
	}

	@Override
	public int queryUserChargeCountListCount(Map<String, Object> parms) {
		SqlSession sqlSession = getSqlSession();
		try {
			ChargeCountMapper operation = sqlSession.getMapper(ChargeCountMapper.class);
			return operation.queryUserChargeCountListCount(parms);
		}catch(Exception e) {
			e.printStackTrace();
		}finally {
			sqlSession.close();
		}
		
		return 0;
	}

	@Override
	public List<UserChargeCountBean> queryUserChargeCountListPage(
			Map<String, Object> parms) {
		SqlSession sqlSession = getSqlSession();
		try {
			ChargeCountMapper operation = sqlSession.getMapper(ChargeCountMapper.class);
			return operation.queryUserChargeCountListPage(parms);
		}catch(Exception e) {
			e.printStackTrace();
		}finally {
			sqlSession.close();
		}
		
		return null;
	}
	
	

}
